<!DOCTYPE html>
<html lang="en">
#parse('base/head.html')
<body class="no-skin">

<div class="main-container ace-save-state" id="main-container">

    <div class="main-content">
        <div class="main-content-inner">
            <div class="page-content">
				<div class="hidden" >
					<input class="col-xs-12 col-sm-10" type="text"  id="form-field-villageId" placeholder="villageId" value="$!{villageId}" />
					<input class="col-xs-12 col-sm-10" type="text"  id="form-field-townId" placeholder="townId" value="$!{townId}" />
				</div>
                <div class="row">
                    
                    <div class="col-sm-12">
						<div class="row col-md-12 fp-toolbar fpxmList" >
							<button onclick="detailClick_pro()" type="button" class="btn btn-sm btn-primary pull-left" ><span class="ace-icon fa fa-plus icon-on-right"></span>新增</button>
							<button onclick="deleteBySelectIds()" type="button" class="btn btn-sm btn-primary pull-left" ><span class="ace-icon fa fa-trash icon-on-right"></span>删除</button>
						</div>
                        <div class="row">
                            <div class="col-sm-12">
								<table id="grid-table"></table>
								<table id="fpxm-project-list"></table>
                                <div id="fpxm-project-list-pager"></div>
                            </div>
                        </div>
                    </div>
                <div/>
            </div>
        </div><!-- /.page-content -->
    </div>
</div>
</body>
#parse('base/footer.html')
<script>
    var projectType = '';
    jQuery(function ($) {
        menuActive(2);
        $("#projectSearchBtn").on('click',function () {
        	console.log("projectSearchBtn click");
            jQuery("#fpxm-project-list").jqGrid('setGridParam',{
				datatype:'json',
				mtype : "POST",
				postData:{'projectName':$("#form-field-project-name").val(),
					'projectType':$("#form-field-project-type  option:selected").val()
				}, //发送数据
				page:1
			}).trigger("reloadGrid");
        });

    });
</script>
<!-- 项目列表 -->
<script type="text/javascript">
    function reloadGridData() {
		console.log("reloadGridData...");
        jQuery("#fpxm-project-list").jqGrid('setGridParam',{
            datatype:'json',
			mtype : "POST",
            postData:{'projectName':$("#form-field-project-name").val(),
                'projectType':$("#form-field-project-type  option:selected").val()
			}, //发送数据
            page:1
        }).trigger("reloadGrid");
    }
	var parentBodyHeight = $('#left-gov-tree', window.parent.document).height()||800;
    //var pkh_parent_column = $("#fpxm-project-list").closest('[class*="col-"]').closest('h4');
    var widget_header = $(".fpxmList");
	    //resize to fit page size
    $(window).on('resize.jqGrid', function () {
        $("#fpxm-project-list").jqGrid( 'setGridWidth', widget_header.width()-24 );
    });
    $("#fpxm-project-list").jqGrid({
        url : '$!webPath/xxgl/getlistByType?infoType=${infoType}',
        datatype : "json",
		mtype : "POST",
        height : parentBodyHeight-435	,
        autowidth: true,
        colNames : [ 'id','序号','置顶','标题','阅读次数','发布日期','过期日期','操作'],
        colModel : [
            {name : 'infoId',key:true,hidden:true},
			{name : 'rownum',width:40,
				formatter: function (cellvalue, options, rowObject) {
					return options.rowId;
				}},
            {name : 'isTopName',width:40},
            {name : 'title'},
            {name : 'readNum',width:60},
			{name : 'pubDate'},
			{name : 'expDate'},
            {name : 'myac',index : '', width:100,
//								formatter:'actions',
                formatter: function (cellvalue, options, rowObject) {

                    var topA
                    if(rowObject.isTop == 1){
                        topA =  '<a  onclick="cacelTop('+options.rowId+')">取消置顶</a> &nbsp;'
                    }else{
                        topA = '<a  onclick="setTop('+options.rowId+')">置顶</a>&nbsp;'
                    }
                    var detail='<a  onclick="updInfo('+options.rowId+')">编辑</a>&nbsp;' +
                                topA +
                                '<a  onclick="detail('+options.rowId+')">详细</a>'
                    return detail;
                }

            }
        ],
        jsonReader : {
            root : "resultList",
            page : "page",
            total : "totalPages",
            records : "totalRecords",
            rows : "resultList"
        },
		multiselect: true,//复选框
        rowNum:10,
        rowList:[10,20,30],
        pager: '#fpxm-project-list-pager',
        // viewrecords : true,
        loadComplete : function() {
			var table = this;
			setTimeout(function(){
				styleCheckbox(table);
				
				updateActionIcons(table);
				updatePagerIcons(table);
				enableTooltips(table);
			}, 0);

			$(table).siblings(".norecords").remove(); 
			var rowNum = parseInt($(table).getGridParam("records"), 10);   
			if (rowNum <= 0) {   
				$(table).parent().append("<div  class=\"norecords\">没有数据...</div>");
				$(table).siblings(".norecords").show(); 								
			} 
        }
    });
	function detailClick_pro(){
        parent.frames[0].location.href  = "$!webPath/xxgl/infoAdd?infoType=$!infoType"
	};
	function deleteBySelectIds(){
        var ids = $("#fpxm-project-list").jqGrid('getGridParam','selarrrow');
        $.ajax({
            type: "POST",
            dataType: "Json",
            url: "$!webPath/xxgl/batchDel",
            data: {
                ids: ids.join(','),
                infoType: '$!infoType'
            },
            success: function (result) {
                parent.frames[0].location.href = "$!webPath/xxgl/fpzcList?infoType=$!infoType"
            },
            error: function (data) {
                alert(22);
            }
        });
    };
    function setTop(id){
        $.ajax({
            type: "POST",
            dataType: "Json",
            url: "$!webPath/xxgl/setTop",
            data: {
                id: id,
                infoType: '$!infoType'
            },
            success: function (result) {
                parent.frames[0].location.href = "$!webPath/xxgl/fpzcList?infoType=$!infoType"
            },
            error: function (data) {
                alert(22);
            }
        });
    };
    function cacelTop(id){
        $.ajax({
            type: "POST",
            dataType: "Json",
            url: "$!webPath/xxgl/cacelTop",
            data: {
                id: id,
                infoType: '$!infoType'
            },
            success: function (result) {
                parent.frames[0].location.href = "$!webPath/xxgl/fpzcList?infoType=$!infoType"
            },
            error: function (data) {
                alert(22);
            }
        });
    };
    function detail(id){
        parent.frames[0].location.href = "$!webPath/xxgl/detail?id=" + id;
    };
    function updInfo(id){
        parent.frames[0].location.href = "$!webPath/xxgl/infoAdd?infoType=$!infoType&id=" + id;
    };
</script>
</html>
